package com.pm.web.controller.buglist;


import com.pm.buglist.domain.BugAnalysis;
import com.pm.buglist.service.BugAnalysisService;
import com.pm.common.annotation.Log;
import com.pm.common.core.controller.BaseController;
import com.pm.common.core.domain.AjaxResult;
import com.pm.common.enums.BusinessType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * bugs分析对策表 前端控制器
 * </p>
 *
 * @author wwm
 * @since 2023-12-14
 */
@RestController
@RequestMapping("/business/bug-analysis")
public class BugAnalysisController extends BaseController {

    @Resource
    private BugAnalysisService analysisService;

    @Log(title = "bugs分析:新增",businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult addBugAnalysis(@RequestBody BugAnalysis analysis){
        return analysisService.insertAnalysis(analysis);
    }

    @Log(title = "bugs分析:修改",businessType = BusinessType.UPDATE)
    @PreAuthorize("@ss.hasPermi('business:bugAnalysis:update')")
    @PostMapping("/update")
    public AjaxResult updateBugAnalysis(@RequestBody BugAnalysis analysis){
        return analysisService.updateAnalysis(analysis);
    }

    @GetMapping("/history/{bid}")
    public AjaxResult getAnalysisHistoryLog(@PathVariable("bid")Long bid){
        return analysisService.findAnalysisLogByBid(bid);
    }

}

